package com.sinog.front.controller.basic.common;

import com.sinog.core.model.UserDTO;
import com.sinog.core.util.JsonUtil;
import com.sinog.core.utilbean.Constants;
import com.sinog.core.utilbean.Result;
import com.sinog.front.feign.basic.common.CommonBasicService;
import com.sinog.front.service.user.UserFacade;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

/**
 * @desc basic公用控制器
 * @author hak
 * @date 2019年7月1日 12点54分
 */
@RestController
public class CommonBasicController {

    @Resource
    private UserFacade userFacade;
    @Resource
    private CommonBasicService commonBasicService;

    /**
     * 获取角色对应的机构级别
     * @return String
     */
    @GetMapping("/basic/common/getOrgLevelList")
    public String getOrgLevelList() {
        UserDTO loginUser = userFacade.getAuthentication();
        Result result = commonBasicService.getOrgLevelList(loginUser.getLevel());
        String json = "";
        if(Constants.Number.NUM_ONE.equals(result.getCode())) {
            json = JsonUtil.toText(result.getData());
        }
        return json;
    }
}